package statePattern

/**
 * 电视机,对应状态模式中的环境角色
 */
class TV {
    //电视机可以看的频道
    private val cctV1 = CCTV1()
    private val cctV2 = CCTV2()
    private val cctV3 = CCTV3()
    private val cctV4 = CCTV4()

    private var channel: Channel? = null
    private fun setChannel(channel: Channel) {
        this.channel = channel
    }

    fun disCCTV1() {
        this.setChannel(cctV1)
        this.channel?.display()
    }

    fun disCCTV2() {
        this.setChannel(cctV2)
        this.channel?.display()
    }

    fun disCCTV3() {
        this.setChannel(cctV3)
        this.channel?.display()
    }

    fun disCCTV4() {
        this.setChannel(cctV4)
        this.channel?.display()
    }
}